<?php
class ModelDesignLayout extends Model {
	public function addLayout($data) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "layout SET `name` = '" . $this->db->escape($data['name']) . 
			"', route = '" . $this->db->escape($data['route']) . 
			"', status = '" . (int)$data['status'] . "'");
	}
	
	public function editLayout($layout_id, $data) {
		$this->db->query("UPDATE " . DB_PREFIX . "layout SET `name` = '" . $this->db->escape($data['name']) . 
			"', route = '" . $this->db->escape($data['route']) . 
			"', status = '" . (int)$data['status'] . 
			"' WHERE layout_id = '" . (int)$layout_id . "'");
	}
	
	public function getLayout($layout_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout WHERE layout_id = '" . (int)$layout_id . "'");
		return $query->row;
	}
		 
	public function getLayouts() {
		$sql = "SELECT * FROM " . DB_PREFIX . "layout ORDER BY `name`";
		$query = $this->db->query($sql);
		return $query->rows;
	}
	
	public function getTotalLayouts() {
      	$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "layout");
		return $query->row['total'];
	}
}
?>